var Hexo = require('hexo');
var hexo = new Hexo(process.cwd(), {});
hexo.init().then(function() {
    // ...
    hexo.extend.generator.register('archive2', function(locals) {
        return {
            path: 'archives-2/index.html',
            data: locals.posts,
            layout: ['post']
        }
    });

    hexo.call('generate', {}).then(function() {});
});